package com.java01;

import java.util.Arrays;

public class twelfthjava {
    public static void main(String[] args) {
        int arr01[] = {24,65,90,56,19};
        int temp = 0;
        for (int i = 0;i < arr01.length-1;i++){
            for (int j = 0;j < arr01.length-1-i;j++){
                if (arr01[j+1]<arr01[j]){
                    temp = arr01[j];
                    arr01[j] = arr01[j+1];
                    arr01[j+1] = temp;
                }
            }
        }
        for (int i = 0; i < arr01.length;i++){
            System.out.print(arr01[i]+" ");
        }
    }
}

class TwoDimensionalArray01{
    public static void main(String[] args) {
        int arr[][] = {{0,0,0,0,0,0},{0,0,1,0,0,0},{2,0,4,0,5,0},{0,0,0,0,0,0}};
        for (int i = 0;i < arr.length;i++){
            for (int j = 0;j<arr[i].length;j++){
                System.out.print(arr[i][j]);
            }
            System.out.println();
        }
    }
}

class TwoDimensionalArray02{
    public static void main(String[] args) {
        int[][] arr = new int[10][];
        for (int i = 0;i < arr.length;i++){
            arr[i] = new int[i + 1];
            Arrays.fill(arr[i], i + 1);
        }
        for (int[] ints : arr) {
            for (int anInt : ints) {
                System.out.print(anInt + "\t");
            }
            System.out.println();
        }
    }
}

class TwoDimensionalArray03{
    public static void main(String[] args) {
        int [][] arr = new int[10][];
        for (int i = 0;i < arr.length;i++){
            arr[i] = new int[i+1];
            //给每个一维数组（行）赋值
            for (int j = 0; j < arr[i].length;j++){
                if (j==0||j==arr[i].length-1){
                    arr[i][j] = 1;
                }else {
                    arr[i][j] = arr[i-1][j] + arr[i-1][j-1];
                }
            }
        }
        for (int[] ints : arr){
           for (int anInt : ints){
               System.out.print(anInt+"\t");
           }
            System.out.println();
        }
    }
}

class homework01{
    public static void main(String[] args) {
        int[] arr = {10,23,45,79,90};
        int num = 46,index = -1;
        for (int i = 0;i < arr.length;i++){
            if (arr[i]>num){
                index = i;
                break;
            }
        }
        if (index == -1){
            index = arr.length;
        }
        int[] arr01 = new int[arr.length+1];
        for (int i = 0,j = 0;i < arr01.length;i++){
            if (i == index){
                arr01[i] = num;
            }else {
                arr01[i] = arr[j];
                j++;
            }
        }
        arr = arr01;
        for (int value : arr) {
            System.out.print(value + "\t");
        }
    }
}

